package com.itcam.ai.utils;

import com.fasterxml.jackson.core.JsonParser;
   import com.fasterxml.jackson.databind.DeserializationContext;
   import com.fasterxml.jackson.databind.JsonDeserializer;
   import com.fasterxml.jackson.databind.JsonNode;

   import java.io.IOException;

   public class CustomLongDeserializer extends JsonDeserializer<Long> {
       @Override
       public Long deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException {
           JsonNode node = jsonParser.getCodec().readTree(jsonParser);
           JsonNode chatIdNode = node.get("chatId");

           // 检查 chatIdNode 是否为 null
           if (chatIdNode == null || chatIdNode.isNull()) {
               return null; // 或者返回一个默认值，例如 0L
           }

           return chatIdNode.asLong();
       }
   }
   